package miroshnichenko.gallery.web;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.DataBinder;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.tags.BindErrorsTag;
import sun.plugin.liveconnect.SecurityContextHelper;

@Controller
@RequestMapping(value = "/login")
public class LoginController {

    @RequestMapping(method = RequestMethod.GET)
    public String login() {
        return "login";
    }

    @RequestMapping(method = RequestMethod.GET, params = "failure")
    public String loginFailureHandle(@RequestParam boolean failure, Model model) {
        if (failure) model.addAttribute("loginFailure", "Invalid email or password.");
        return "login";
    }
}
